*------------------------------------------------------------------------------*
* The Effect of Property Assessment Reductions on Tax Deliquency * 
* National Tax Journal *
* Tables and Figures - Tax Delinquency *
* November 2024 *
*------------------------------------------------------------------------------*
gl path1 "/Users/fernandaalfaro/Library/CloudStorage/GoogleDrive-fag019@alumnos.ucn.cl/My Drive/Detroit taxes/split rate/"
gl path2 "$path1/Data"
gl path3 "/Users/fernandaalfaro/Library/CloudStorage/GoogleDrive-fag019@alumnos.ucn.cl/My Drive/Detroit taxes/Split rate tax compliance"
gl path4 "$path1/Graphs"

use "$path2/New Data/tax_due_V.dta", clear										/* 1.869.459 */

* Sample
gl cond dep_dummy_200 <. & tbill_l1_1000 <. & dtbill_lag1 != 1
*------------------------------------------------------------------------------*
* Descriptive Tables
*------------------------------------------------------------------------------*	
	*** Table 2 - Proportion of Negative Changes in Tax Bill Over Time ***
	table (tax_year) if tax_year > 2011 & $cond , statistic(mean tb_neg) 		///
		statistic(mean tbill_ratio_lag0) statistic(n tb_neg) 
				
	*** Table 3 - Number of Positive (including zero) and Negative Annual Tax Bill Changes ***
	tab tax_year if tax_year > 2011 & tb_neg == 1 		& $cond
	tab tax_year if tax_year > 2011 & tb_neg == 0 		& $cond
	tab tax_year if tax_year > 2011 & dtbill_lag1 != 1 	& $cond
		
		
	*** Table 4 - Summary Statistics for Key Variables for Residential Improved Parcels ***
	su dep_dummy_200 tbill_l1_1000 total_mills pre if $cond
	
	*** Figures 1 & 2 ***
	keep id tax_year parcelnumber nhood nhoodnum tax_bill

	duplicates 		tag id parcelnumber, gen(aux1)
	duplicates		tag id nhood	   , gen(aux2)
	drop if 		aux1 != aux2
	duplicates drop tax_year id, force
	reshape 		wide tax_bill, i(id parcelnumber) j(tax_year)

	* Change Ratio
	gen 	rtb_2011_2017    = tax_bill2011/tax_bill2017
	gen 	rattb_dummy_2017 = 0
	replace rattb_dummy_2017 = 1 if rtb_2011_2017 > 1 & rtb_2011_2017 <.
	replace rattb_dummy_2017 =.  if rtb_2011_2017 ==.

	gen dtb_2011_2017 = (tax_bill2017 - tax_bill2011)/tax_bill2011
	
	* Collapse at Neiborhood level
	collapse rattb_dummy_2017 dtb_2011_2017, by(nhoodnum nhood)
	drop if  nhoodnum ==.
	
	save "$path2/New Data/tax_map.dta", replace 									/* N = 54 */
	
	* Map
	cd "$path3"
	shp2dta using Master_Plan_Neighborhoods_Detroit, data(dDetroit) coord(cDetroit) replace

	use 	  "$path3/dDetroit.dta", clear
	rename 	  NHOODNUM nhoodnum
	merge 1:1 nhoodnum using "$path2/New Data/tax_map.dta", nogen

	format %3.2f rattb_dummy_2017
	format %3.2f dtb_2011_2017
		
	pctile pctl_2017_ratio_tb  = dtb_2011_2017   , nq(4)
	pctile pctl_2017_dummy_tb  = rattb_dummy_2017, nq(4)
	
	* Tax Bill
	spmap rattb_dummy_2017 using "$path3/cDetroit.dta", id(_ID) name(fig1, replace)	 	 ///
		fcolor(Greys2) title(Figure 1: Proportion, 									 	 ///
		size(small) color(black*0.8)) clmethod(quantile) ocolor(white white white white) ///
		osize(0.09 0.09 0.09 0.09)
	graph export "$path4/HM_TB_prop_2017.png", replace as(png) 

	spmap dtb_2011_2017 using "$path3/cDetroit.dta", id(_ID) name(fig2, replace)	 	 ///
		fcolor(Greys2) title(Figure 2: Percentage Change, 							 	 ///
		size(small) color(black*0.8)) clmethod(quantile) ocolor(white white white white) ///
		osize(0.09 0.09 0.09 0.09)
	graph export "$path4/HM_DTB_2011_2017.png", replace as(png) 
	
	graph combine fig1 fig2, graphregion(fcolor(white)) col(2) 					///
		title(Residential Parcels Experiencing Tax Bill Reduction between 2011-2017 by Neighborhood, size(small) color(black*0.8))
		
	graph export "$path4/maps.png", replace as(png) 
*------------------------------------------------------------------------------*
* Regressions Tables
*------------------------------------------------------------------------------*
	use "$path2/New Data/tax_due_V.dta", clear

	*** Table 5 - Probability of Becoming Tax Delinquent Regression Analysis ***
	eststo clear
	eststo m1: reg 		dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo m2: xtreg	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	
			   logit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo m3: margins, dydx(tbill_l1_1000) post
			   logit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo m4: margins, dydx(tax_year) post
			   logit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo m5: margins, dydx(total_mills) post
			   logit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo m6: margins, dydx(pre) post
	
			   xtlogit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo m7: margins, dydx(tbill_l1_1000) post
			   xtlogit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo m8: margins, dydx(tax_year) post
			   xtlogit 	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo m9: margins, dydx(total_mills) post
			   xtlogit	dep_dummy_200 tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo m10:margins, dydx(pre) post


	* Estimated coefficients - LPM & LPM FE *
	esttab 	m1 m2 using "$path4/obs_comp.rtf", replace  									///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019" _cons "Constant" total_mills "Total Millage Rate"		///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers mtitles("LPM" "LPM FE" "Logit" "Logit FE")
	
	* Marginal effects - Logit *
	esttab m3 m4 m5 m6 using "$path4/logit_ma.rtf", replace 								///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	* Marginal effects - Logit FE *
	esttab m7 m8 m9 m10 using "$path4/xtlogit_ma.rtf", replace 								///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	
	*** Online Appendix Table 8 ***
	eststo clear
	eststo n1: reg 		dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo n2: xtreg	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	
			   logit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo n3: margins, dydx(tbill_l1_1000) over(dtbill_lag1) post
			   logit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo n4: margins, dydx(tax_year) post
			   logit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo n5: margins, dydx(total_mills) post
			   logit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1
	eststo n6: margins, dydx(pre) post
	
			   xtlogit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo n7: margins, dydx(tbill_l1_1000) over(dtbill_lag1) post
			   xtlogit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo n8: margins, dydx(tax_year) post
			   xtlogit 	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo n9: margins, dydx(total_mills) post
			   xtlogit	dep_dummy_200 i.dtbill_lag1#c.tbill_l1_1000 i.tax_year total_mills i.pre if dtbill_lag1 != 1, fe iter(3)
	eststo n10:margins, dydx(pre) post


	* Estimated coefficients - LPM & LPM FE *
	esttab 	n1 n2 using "$path4/obs_comp2.rtf", replace  									///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019" _cons "Constant" total_mills "Total Millage Rate"		///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers mtitles("LPM" "LPM FE" "Logit" "Logit FE")
	
	* Marginal effects - Logit *
	esttab n3 n4 n5 n6 using "$path4/logit_ma2.rtf", replace 								///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	* Marginal effects - Logit FE *	
	esttab n7 n8 n9 n10 using "$path4/xtlogit_ma2.rtf", replace 							///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
*------------------------------------------------------------------------------*
* The Effect of Property Assessment Reductions on Tax Foreclosure *
* National Tax Journal *
* Tables and Figures - Tax Foreclosure *
* November 2024 *
*------------------------------------------------------------------------------*
clear all

gl path1 "/Users/fernandaalfaro/Library/CloudStorage/GoogleDrive-fag019@alumnos.ucn.cl/My Drive/Detroit taxes/split rate/"
gl path2 "$path1/Data"
gl path3 "$path1/Output/Foreclosure"

use "$path2/foreclosure_logits.dta", clear

* Sample
gl  cond dep_d_fr <. & tbill_l1_1000 <. & dtbill_lag1 != 1
*------------------------------------------------------------------------------*
* Descriptive Tables
*------------------------------------------------------------------------------*		
	*** Table 6 - Number of Properties at Risk of Tax Foreclosure ***
	tab dep_d_fr if $cond
*------------------------------------------------------------------------------*
* Regressions Tables
*------------------------------------------------------------------------------*
	*** Table 7 - Probability of Becoming Tax Foreclosed Regression Analysis ***
	eststo clear
	eststo c1: reg 		dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c2: xtreg	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	
			   logit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c3: margins, dydx(tbill_l1_1000) post
			   logit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c4: margins  tax_year, post
			   logit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c5: margins, dydx(total_mills) post
			   logit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c6: margins, dydx(pre) post
	
			   xtlogit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c7: margins, dydx(tbill_l1_1000) post
			   xtlogit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c8: margins, dydx(tax_year) post
			   xtlogit 	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c9: margins, dydx(total_mills) post
			   xtlogit	dep_d_fr tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c10:margins, dydx(pre) post


	* Estimated coefficients - LPM & LPM FE *
	esttab 	c1 c2 using "$path3/obs_comp.rtf", replace  									///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019" _cons "Constant" total_mills "Total Millage Rate"		///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers mtitles("LPM" "LPM FE" "Logit" "Logit FE")
	
	* Marginal effects - Logit *
	esttab c3 c4 c5 c6 using "$path3/logit_ma.rtf", replace 								///
		drop(0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 						///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	* Marginal effects - Logit FE *	 	
	esttab c7 c8 c9 c10 using "$path3/xtlogit_ma.rtf", replace 								///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	*** Online Appendix Table 9 ***
	eststo clear
	eststo c1: reg 		frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c2: xtreg	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	
			   logit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c3: margins, dydx(tbill_l1_1000) post
			   logit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c4: margins  tax_year, post
			   logit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c5: margins, dydx(total_mills) post
			   logit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond
	eststo c6: margins, dydx(pre) post
	
			   xtlogit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c7: margins, dydx(tbill_l1_1000) post
			   xtlogit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c8: margins, dydx(tax_year) post
			   xtlogit 	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c9: margins, dydx(total_mills) post
			   xtlogit	frcl tbill_l1_1000 i.tax_year total_mills i.pre if $cond, fe iter(3)
	eststo c10:margins, dydx(pre) post


	* Estimated coefficients - LPM & LPM FE *
	esttab 	c1 c2 using "$path3/obs_comp_appx.rtf", replace  								///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019" _cons "Constant" total_mills "Total Millage Rate"		///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers mtitles("LPM" "LPM FE" "Logit" "Logit FE")
			
	* Marginal effects - Logit *
	esttab c3 c4 c5 c6 using "$path3/logit_ma_appx.rtf", replace 							///
		drop(0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 						///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
	
	* Marginal effects - Logit FE * 	
	esttab c7 c8 c9 c10 using "$path3/xtlogit_ma_appx.rtf", replace 						///
		drop(2012.tax_year 0.pre) coeflabel(tbill_l1_1000 "Tax Bill Lagged 1 Year" 			///
			2013.tax_year "Year 2013" 2014.tax_year "Year 2014" 2015.tax_year "Year 2015" 	///
			2016.tax_year "Year 2016" 2017.tax_year "Year 2017" 2018.tax_year "Year 2018" 	///
			2019.tax_year "Year 2019"  total_mills "Total Millage Rate"						///
			1.pre "Principal Residence Exemption" ) b(%9.3f) se(%9.3f) nodepvars 			///
			nonumbers
